
Research
NPM targeted by malware campaign mimicking familiar library names
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
is-builtin-module
Advanced tools
The is-builtin-module npm package is used to check if a given module name corresponds to a Node.js built-in module. This can be useful when developing tools that need to differentiate between built-in modules and third-party modules, such as bundlers, linters, or dependency analysis tools.
Check if a module is a built-in module
This feature allows you to check if a given string corresponds to a Node.js built-in module. In the code sample, 'fs' is recognized as a built-in module, while 'express' is not.
const isBuiltinModule = require('is-builtin-module');
console.log(isBuiltinModule('fs')); // true
console.log(isBuiltinModule('express')); // false
The 'builtin-modules' package provides a list of the built-in modules of Node.js. It is similar to 'is-builtin-module' but instead of checking if a module is built-in, it provides the full list of built-in modules. You can use this list to check for built-in modules manually.
The 'resolve' package is a module resolution algorithm for Node.js, similar to the one used by 'require'. It can be used to check if a module is resolvable and, by extension, to infer if it is a built-in module. However, it is more general-purpose and not specifically designed for checking built-in modules.
Check if a string matches the name of a Node.js builtin module
Note that this matches based a static list of modules from the latest Node.js version. If you want to check for a module in the current Node.js, use the core isBuiltin
method.
npm install is-builtin-module
import isBuiltinModule from 'is-builtin-module';
isBuiltinModule('fs');
//=> true
isBuiltinModule('fs/promises');
//=> true
isBuiltinModule('node:fs/promises');
//=> true
isBuiltinModule('unicorn');
//=> false
FAQs
Check if a string matches the name of a Node.js builtin module
The npm package is-builtin-module receives a total of 6,316,259 weekly downloads. As such, is-builtin-module popularity was classified as popular.
We found that is-builtin-module demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
Research
Socket's research uncovers three dangerous Go modules that contain obfuscated disk-wiping malware, threatening complete data loss.
Research
Socket uncovers malicious packages on PyPI using Gmail's SMTP protocol for command and control (C2) to exfiltrate data and execute commands.